#pragma once
#include <QMap>

#include "Command.h"

class CmdMgr {
 public:
  static CmdMgr& instance();
  bool initialize();
  void unInitialize();

  void loadQBMenu();
  void loadQBWoptions();
  void loadClickPageConfig(bool isSave = false);

  bool execCmd(int id);
  bool execCmd(int id, const QString& paras);
  bool execCmd(const QString* name, const QJsonObject* params);

  int cmdWindowId();  // tab id or top window id
  Command* command(int id);

  void removePageRedPoint(int id);

  void addCommonPage(int id);
  void setCommonPages(int* ids, int size);
  bool isCommonPage(int id);
  void removeCommonPage(int id);
  const QVector<int>& commonPages() { return m_commonPages; }
  void setIasMenu(const QString& iasmenu);
  const QString& getIasMenu() { return m_iasmenu; }

  const QString LoadURL(const char* sKey);

 private:
  CmdMgr();
  void LoadCmdConfig();

 private:
  QMap<int, Command> m_cmds;
  QSet<int> m_noRedpages;
  QVector<int> m_commonPages;
  QString m_iasmenu;
  QMap<QString, QString> m_options;
};
